<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@page pageEncoding="UTF-8"%>
<%@include file="../WEB-INF/jspf/controlesessao.jspf"%>

<sql:query var="query" dataSource="jdbc/dbo_MicrosoftSQLServer">
    select c.*, desc_tipocurso
    from Cursos c
    inner join TipoCursos on c.id_tipocurso=TipoCursos.id_tipocurso
    where exists(select 1 from Grades g where g.id_curso=c.id_curso
    and g.id_componente=?)
    order by nome_curso
    <sql:param value="${param.id_componente}"/>
</sql:query>
<c:choose>
    <c:when test="${!empty query.rows}">
        <label class="lbInput">Cursos<em>*</em></label>
        <select id="id_curso" name="id_curso" class="required" >
            <c:forEach var="row" items="${query.rows}">
                <option value="${row.id_curso}" ${row.id_curso==param.id_curso?'selected':''}>
                    ${row.nome_curso} - ${row.desc_tipocurso}
                </option>
            </c:forEach>
        </select>
    </c:when>
    <c:otherwise>
        <p style="font-size: 12pt; color: red">Nenhum curso encontrado.</p>
    </c:otherwise>
</c:choose>